class MyPromise{
    static all(proms) {
        return new MyPromise((resolve, reject) => {
            const results = proms.map(val => {
                const obj = {
                    result: undefined,
                    isResolved: false
                }
                if(val instanceof MyPromise){
                    val.then(data => {
                        obj.result = data;
                        obj.isResolved = true;
                        //判断是否所有的全部完成
                        const unResolved = results.find(r => !r.isResolved)
                        if (!unResolved) {
                            //全部完成
                            resolve(results.map(r => r.result));
                        }
                    }, reason => {
                        reject(reason);
                    })
                }else{
                    obj.result=value
                    obj.isResolved = true;
                }
               
                return obj;
            })
        })
    }
}